package net.dlz.example.service;

import net.dlz.example.domain.SearchStreetRequest;
import net.dlz.example.domain.Street;
import net.dlz.example.domain.StreetExample;
import net.dlz.example.mapper.StreetMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

@Service
public class StreetServiceImpl implements StreetService{
    @Autowired
    private StreetMapper streetMapper;
    @Override
    public List<Street> listStreet() {
        return streetMapper.selectByExample(new StreetExample());
    }

    @Override
    public int deleteStreetByPrimaryKey(String street_Id) {
        return streetMapper.deleteByPrimaryKey(street_Id);
    }

    @Override
    public Street findStreetByPrimaryKey(String street_Id) {
        return streetMapper.selectByPrimaryKey(street_Id);
    }


    @Override
    public int savaStreet(Street street){

        if (StringUtils.isNotBlank(street.getStreetId())){
            return streetMapper.updateByPrimaryKey(street);
        }else{
            return streetMapper.insert(street);
        }


    }

//    @Override
//    public List<Street> selectStreetTypeCount(String streetName) {
//        return streetMapper.selectStreetTypeCount(streetName);
//    }
//
//    @Override
//    public List<Street> findStreetByName() {
//        return streetMapper.selectAllStreet();
//    }


    public List<Street> getStreetByDistrictId(String id) {
        return streetMapper.getStreetByDistrictId(id);
    }

}
